"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var api_1 = require("../../../config/api");
var NewsDetailComponent = /** @class */ (function () {
    function NewsDetailComponent(httpService, route, router) {
        this.httpService = httpService;
        this.route = route;
        this.router = router;
        this.detailData = {
            author: { nick_name: '' },
            last_article: '',
            next_article: '',
            title: '',
            created_at: ''
        };
        this.categoryID = 0;
        this.newestInfo = [];
        this.classifyList = [];
    }
    NewsDetailComponent.prototype.ngOnInit = function () {
        var _this = this;
        this.route.queryParams.subscribe(function (res) {
            _this.categoryID = +res.categoryId || 0;
        });
        this.getDetail();
        this.getAllArtical();
        this.getClassifyList();
    };
    // 获取详情资讯
    NewsDetailComponent.prototype.getDetail = function (articleId) {
        var _this = this;
        var id = articleId || +this.route.snapshot.params['id'];
        var url = api_1.adSystemApiUrl + "/v1/fddata/posts/detail?postID=" + id;
        return this.httpService.httpGetAuth(url).subscribe(function (data) {
            _this.detailData = data.data;
            document.getElementsByClassName("news-detail-warp")[0].innerHTML = data.data.body;
        });
    };
    // 获取所有最新资讯列表
    NewsDetailComponent.prototype.getAllArtical = function () {
        var _this = this;
        var url = api_1.adSystemApiUrl + "/v1/fddata/posts/list?page=1&pageSize=3";
        return this.httpService.httpGetAuth(url).subscribe(function (data) {
            _this.newestInfo = data.data.data;
        });
    };
    // 获取分类列表
    NewsDetailComponent.prototype.getClassifyList = function () {
        var _this = this;
        var url = api_1.adSystemApiUrl + "/v1/fddata/category/list";
        return this.httpService.httpGetAuth(url).subscribe(function (data) {
            _this.classifyList = data.data;
        });
    };
    // 点击最新资讯，更改内容详情
    NewsDetailComponent.prototype.changeDetail = function (data) {
        this.categoryID = data.category_id;
        this.getDetail(data.id);
    };
    // 点击分类，跳转至新闻列表
    NewsDetailComponent.prototype.turnNewsList = function (categoryId) {
        this.router.navigate(['/home/news-list'], { queryParams: { categoryId: categoryId } });
    };
    NewsDetailComponent = __decorate([
        core_1.Component({
            selector: 'app-news-detail',
            templateUrl: './news-detail.component.html',
            styleUrls: ['./news-detail.component.scss']
        })
    ], NewsDetailComponent);
    return NewsDetailComponent;
}());
exports.NewsDetailComponent = NewsDetailComponent;
